﻿namespace BigfootMVC.DNN
{
    
    /// <summary>
    /// Constant Parameters used throughtout the application
    /// </summary>
    public class Params
    {

        /// <summary>
        /// Creates a unique parameter for your module that is unique for this DNN installation. Does not differentiate accross portals, or module instances.
        /// This is particularly useful for things like the database provider cache key etc.
        /// </summary>
        /// <param name="key">The parameter name to create</param>
        /// <param name="moduleShortName">This is the short name of your module</param>
        /// <returns>Returns {key}_mn_{ModuleShortName}</returns>
        public static string HostKey(string key, string moduleShortName)
        {
            return key + "_mn_" + moduleShortName;
        }

        /// <summary>
        /// Creates a unique parameter for your module that is unique for this specific portal. Does not differentiate accross module instances within this portal.
        /// This is particularly useful for things like portal specific data caches etc.
        /// </summary>
        /// <param name="key">The parameter name to create</param>
        /// <param name="portalId">The id for the portal this key refers to</param>
        /// <param name="moduleShortName">This is the short name of your module</param>
        /// <returns>Returns {key}_mn_{moduleshortname}_pid_{portalId}</returns>
        public static string PortalKey(string key, int portalId, string moduleShortName)
        {
            return key + "_mn_" + moduleShortName + "_pid_" + portalId;
        }

        /// <summary>
        /// Creates a unique parameter for your module that is unique for this specific module instance
        /// This is particularly useful for things like module instance route etc.
        /// </summary>
        /// <param name="key">The parameter name to create</param>
        /// <param name="moduleId">The id for the module instance this key refers to</param>
        /// <returns>Returns {key}_pid_{portalId}</returns>
        public static string ModuleKey(string key, int moduleId)
        {
            return key + "_mid_" + moduleId;
        }

       
        /// <summary>
        /// Well known querystring parameters used in the module
        /// </summary>
        public class QS
        {
            /// <summary>
            /// Holds the route data for a particular module id in the page
            /// </summary>
            public static string Route(int moduleId) { return ModuleKey("route", moduleId); }

            /// <summary>
            /// Holds the route data for a module. Used in ajax request, where there is only one module being executed
            /// </summary>
            /// <param name="moduleShortName">This is the short name of your module</param>
            public static string AjaxRoute(string moduleShortName) { return HostKey("route", moduleShortName); } 
        }
        
        /// <summary>
        /// Well known Cache parameters used in the module. These are application wide settings. Becareful with these as they are shared accross the dnn install
        /// </summary>
        public class Cache
        {
            /// <summary>
            /// Sotres the provodier configuration for the application
            /// </summary>
            public static string ProviderConfiguration(string moduleShortName) { return HostKey("ProviderConfiguration", moduleShortName); } 

            /// <summary>
            /// Stores the portal id data path. This is specific for the portalid specified
            /// </summary>
            public static string DataFolder(int PortalID, string moduleShortName) { return PortalKey("DataFolderPath", PortalID, moduleShortName); }

       
        }
        
    }
}
